<g:set var="entityName" value="${message(code: 'courseware.label', default: 'Courseware')}" />
 <g:form action="save" method="post" >
    <div class="dialog">
        <table>
            <tbody>
                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="title"><g:message code="courseware.title.label" default="Title" /></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: coursewareInstance, field: 'title', 'errors')}">
                        <g:textField name="title" maxlength="250" value="${coursewareInstance?.title}" /> 
                    </td>
                </tr>
                <g:if test="${!coursewareInstance?.category}"> 
                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="category"><g:message code="courseware.category.label" default="Category" /></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: coursewareInstance, field: 'category', 'errors')}">
                         <x:selectTree from="${Categorys.findAllBySchoolAndParentIsNull(session.school)}" attribute="children" 
                        name="category.id" class="select"  value="${coursewareInstance?.category?.id}"/>
                     </td>
                </tr>
                </g:if>
                <g:else>
                  <input type="hidden" name="category.id" value="${coursewareInstance?.category?.id}">
                </g:else>
               <tr class="prop">
                    <td valign="top" class="name">
                        <label for="attachments">
                        <a href="javascript:"  class="uploadButton"><g:message code="article.attachments.label" default="attachments" /></a></label>
                    </td>
                    <td valign="top" class="value">
                        <div id="messages"></div>
                        <div id="errors"></div>
                        <div id="attachmentList">
                        <g:each in="${coursewareInstance?.attachments}" var="attachment">
                             <div class='filename' id="${attachment.id}"><a href='javascript:' class='showAttachment'>${attachment.name}(${Math.round(attachment.size/1024)}k)</a>
                             <input type='hidden' name='attachments' value="${attachment.id}">
                             <a href='javascript:' class='deleteAttachment'><g:message code="default.button.delete.label" default="删除" /><g:message code="article.attachments.label" default="attachments" /></a>
                             </div> 
                        </g:each> 
                        </div> 
                    </td>
                </tr> 
                <tr class="prop">
                    <td valign="top" class="name">
                        <label for="content"><g:message code="courseware.content.label" default="Content" /></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: coursewareInstance, field: 'content', 'errors')}">
                        <ckeditor:config    height="300px"    width="80%"  />
                        <ckeditor:editor name="content" >${coursewareInstance?.content}</ckeditor:editor>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="buttons">
        <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
    </div>
</g:form>